<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Set the scheme handlers for the XSLT processor</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.xslt-set-scheme-handler.html">xslt_set_scheme_handler</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.xslt-setopt.html">xslt_setopt</a></div>
 <div class="up"><a href="ref.xslt.html">XSLT (PHP 4) 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.xslt-set-scheme-handlers" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">xslt_set_scheme_handlers</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.6)</p><p class="refpurpose"><span class="refname">xslt_set_scheme_handlers</span> &mdash; <span class="dc-title">Set the scheme handlers for the <acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> processor</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.xslt-set-scheme-handlers-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><span class="type void">void</span></span> <span class="methodname"><strong>xslt_set_scheme_handlers</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$xh</code></span>
   , <span class="methodparam"><span class="type">array</span> <code class="parameter">$handlers</code></span>
   )</div>

  <p class="para rdfs-comment">
   Registers the scheme handlers (XPath handlers) for the document.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.xslt-set-scheme-handlers-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    <dt>
<em><code class="parameter">
xh</code></em></dt>
<dd>
<p class="para"><acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> 处理器连接标识符，由
<span class="function"><a href="function.xslt-create.html" class="function">xslt_create()</a></span> 创建。</p></dd>


    
     <dt>
<em><code class="parameter">handlers</code></em></dt>

     <dd>

      <p class="para">
       An array with the following keys: <em>&quot;get_all&quot;</em>, 
       <em>&quot;open&quot;</em>, <em>&quot;get&quot;</em>, <em>&quot;put&quot;</em>,
       and <em>&quot;close&quot;</em>.
      </p>
      <p class="para">
       Every entry must be a function name or an array in the following
       format: <em>array($obj, &quot;method&quot;)</em>.
      </p>
      <p class="para">
       Note that the given array does not need to contain all of the
       different scheme handler elements (although it can), but it only needs
       to conform to the <em>&quot;handler&quot; =&gt; &quot;function&quot;</em> format
       described above.
      </p>
      <p class="para">
       Each of the individual scheme handler functions called are in the
       formats below:
       <div class="example-contents screen">
<div class="cdata"><pre>
string   get_all(resource processor, string scheme, string rest)
resource open(resource processor, string scheme, string rest)
int      get(resource processor, resource fp, string &amp;data)
int      put(resource processor, resource fp, string data)
void     close(resource processor, resource fp)
</pre></div>
       </div>
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.xslt-set-scheme-handlers-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   没有返回值。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.xslt-set-scheme-handlers-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5440">
    <p><strong>Example #1 <span class="function"><strong>xslt_set_scheme_handlers()</strong></span> example</strong></p>
    <div class="example-contents"><p>
     For example, here is an implementation of the &quot;file_exists()&quot; PHP function.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;Definition&nbsp;of&nbsp;the&nbsp;handler<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">mySchemeHandler</span><span style="color: #007700">(</span><span style="color: #0000BB">$processor</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$scheme</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$rest</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$rest&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$rest</span><span style="color: #007700">,</span><span style="color: #0000BB">1</span><span style="color: #007700">);&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;to&nbsp;remove&nbsp;the&nbsp;first&nbsp;/&nbsp;automatically&nbsp;added&nbsp;by&nbsp;the&nbsp;engine<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">$scheme&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #DD0000">'file_exists'</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;result&nbsp;is&nbsp;embedded&nbsp;in&nbsp;a&nbsp;small&nbsp;xml&nbsp;string<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">return&nbsp;</span><span style="color: #DD0000">'&lt;?xml&nbsp;version="1.0"&nbsp;encoding="UTF-8"?&gt;&lt;root&gt;'&nbsp;</span><span style="color: #007700">.&nbsp;(</span><span style="color: #0000BB">file_exists</span><span style="color: #007700">(</span><span style="color: #0000BB">$rest</span><span style="color: #007700">)&nbsp;?&nbsp;</span><span style="color: #DD0000">'true'&nbsp;</span><span style="color: #007700">:&nbsp;</span><span style="color: #DD0000">'false'</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">'&lt;/root&gt;'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">$SchemeHandlerArray&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'get_all'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'mySchemeHandler'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Start&nbsp;the&nbsp;engine<br /></span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br /></span><span style="color: #0000BB">$xh&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">xslt_create</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">xslt_set_scheme_handlers</span><span style="color: #007700">(</span><span style="color: #0000BB">$xh</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$SchemeHandlerArray</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">xslt_process</span><span style="color: #007700">(</span><span style="color: #0000BB">$xh</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"myFile.xml"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"myFile.xsl"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NULL</span><span style="color: #007700">,&nbsp;array(),&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">xslt_free</span><span style="color: #007700">(</span><span style="color: #0000BB">$xh</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #0000BB">$result</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>
     Then, inside the stylesheet, you can test whether a certain file exists with:
    </p></div>
    <div class="example-contents">
<div class="xmlcode"><pre class="xmlcode">&lt;xsl:if test=&quot;document(&#039;file_exists:anotherXMLfile.xml&#039;)/root=&#039;true&#039;&quot;&gt;
 &lt;!-- The file exist --&gt;
&lt;/xsl:if&gt;</pre>
</div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.xslt-set-scheme-handlers-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.xslt-set-scheme-handler.html" class="function" rel="rdfs-seeAlso">xslt_set_scheme_handler()</a> - Set Scheme handlers for a XSLT processor</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.xslt-set-scheme-handler.html">xslt_set_scheme_handler</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.xslt-setopt.html">xslt_setopt</a></div>
 <div class="up"><a href="ref.xslt.html">XSLT (PHP 4) 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
